package my.edu.model.bills.purchase.entity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import jakarta.validation.groups.Default;
import lombok.Data;
import my.edu.common.validate.groups.Insert;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
public class PurchaseDTO {
    @Null(message = "id必须为空", groups = {Insert.class})
    @NotNull(message = "id不能为空", groups = {Default.class})
    private Long id;
    @NotBlank(message = "编号不能为空", groups = {Default.class})
    private String orderNo;
    @NotNull(message = "日期不能为空", groups = {Insert.class})
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate orderDate;
   @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal purchaseAmount;//购货金额
    private BigDecimal discountRate;//优惠率
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal discountAmount;//优惠金额
    @Min(value = 0, message = "数量必须大于0", groups = {Insert.class})
    private Integer quantity;
    private BigDecimal amountAfterDiscount;//优惠后金额
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal paidAmount;//已付款金额
    private String deliveryMethod;//交货方式
    //private String paymentStatus;//付款状态
    //private String returnStatus;//退货状态
    //private String orderStatus;//对单状态
//    @IntegerPattern(regexp = "^[01]$", message = "审核状态参数错误")
//    private Integer isAudited;//是否审核
    private String remark;
//    private String deliveryMethodName;//送货方式
    @NotNull(message = "供应商id不能为空",groups = {Insert.class})
    @Min(value = 1, message = "供应商id必须大于0", groups ={Insert.class})
    private Long supplierId;
    private String supplierName;
    private String supplierAddress;
    @NotNull(message = "销售人员id不能为空",groups = {Insert.class})
    @Min(value = 1, message = "业务员id必须大于0", groups ={Insert.class})
    private Long salesmanId;//业务员ID
    private String salesmanName;
    //private Long purchaseReturnOrderId;//购货退货单ID
    //private String purchaseReturnOrderNo;//购货退货单号
    private Long settlementAccountId;//结算账户ID
    private String settlementAccountName;
    private Integer isAllocated;//是否分摊
    //private Long auditorId;//审核人ID
    //private String auditorName;//审核人姓名
    private Long logisticsId;//物流ID
    private String logisticsNo;//物流单号
    @Valid
    @NotEmpty(message = "采购明细不能为空",groups = {Insert.class})
    private List<PurchaseDetailOrderDTO> purchaseDetailDTOList;
    private List<PurchaseSalesExpensesDTO> purchaseSalesExpensesDTOList;
}
